Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

146
Vistas
How to solve "cannot read properties of type undefined" when trying to send form input data to the backend?

I am trying to send a username that the user fills out to my server. I already have a post request that sends other information to the server and I would like to use the same post request and just add the new username value into the list of things that im sending. I keep getting this error even though I have given my form input a type="text"

here is my code for the form:

import React, { useState } from "react";

export default function UserForm() {
  const [values, setValues] = useState();

  const onSubmit = async (event) => {
    event.preventDefault();
  };

  function setUserValues() {
    setValues(values.user);
  }

  useState(setUserValues);
  if (values.user === undefined) {
    return;
  }

  return (
    <form onSubmit={onSubmit}>
      <label>User*:</label>
      <input
        type="text"
        value={values.user}
        id="user"
        name="user"
        onChange={setImmediate("user")}
      />
      <button type="submit">Submit</button>
    </form>
  );
}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

try something like this

import React, { useState } from "react";

export default function UserForm() {
  const [values, setValues] = useState();
  
  const edit = (e) => {
    setValues(e.target.value)
  }

  return (
    <form onSubmit={onSubmit}>
      <label>User*:</label>
      <input
        type="text"
        value={values}
        id="user"
        name="user"
        onChange={edit()}
      />
      <button type="submit">Submit</button>
    </form>
  );
}
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda